package com.bfmet;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.OutputStream;

import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.imageio.ImageIO;

import com.bfmet.common.base.GenericMBean;

@ManagedBean
public class TestAction extends GenericMBean {

	public void print(String name) {
		System.out.print("name is:" + name);
	}

	public void getImage() {
		try {
			BufferedImage image = new BufferedImage(200, 200,
					BufferedImage.TYPE_INT_RGB);
			Graphics2D g = image.createGraphics();
			g.drawLine(0, 0, 199, 199);

			// ByteArrayOutputStream baos = new ByteArrayOutputStream();
			OutputStream os = FacesContext.getCurrentInstance()
					.getResponseStream();
			ImageIO.write(image, "jpeg", os);
			os.close();
			// byte[] bytesOut = baos.toByteArray();
			// this.
			// return bytesOut;
		} catch (Exception ex) {
			this.logException(ex);
		}

	}

}
